home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_06 / 9n06102a < prev    next >
Text File  |  1991-04-10  |  982b  |  49 lines

  1. /******************************************
  2. *   file d:\cips\rstring.c
  3. *
  4. *   Functions: This file contains
  5. *            read_string
  6. *            clear_buffer
  7. *            long_clear_buffer
  8. *
  9. *   Purpose: This function reads a string 
  10. *       of input from the keyboard.
  11. *******************************************/
  12.  
  13. #include "d:\cips\cips.h"
  14.  
  15. read_string(string)
  16.         char *string;
  17. {
  18.         int     eof,
  19.                 letter,
  20.                 no_error;
  21.  
  22.         eof = -1;
  23.         no_error = 0;
  24.  
  25.         while((letter = getchar()) != '\n' &&
  26.                letter !=  eof)
  27.            *string++ = letter;
  28.  
  29.         *string = '\0';
  30.         return((letter == eof) ? eof : no_error);
  31. }       /* ends read_string */
  32.  
  33.  
  34. clear_buffer(string)
  35.    char string[];
  36. {
  37.    int i;
  38.    for(i=0; i<MAX_NAME_LENGTH; i++)
  39.       string[i] = ' ';
  40. }
  41.  
  42. long_clear_buffer(string)
  43.    char string[];
  44. {
  45.    int i;
  46.    for(i=0; i<300; i++)
  47.       string[i] = ' ';
  48. }
  49.